/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.alien.admin.modules.message.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author zhouseyi
* @date 2021-11-17
**/
@Entity
@Data
@Table(name="dp_notify_announce")
public class NotifyAnnounce implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "sender_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "发送者id")
    private Long senderId;

    @Column(name = "title",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "消息标题")
    private String title;

    @Column(name = "message",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "消息正文")
    private String message;

    @Column(name = "is_html",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否html片段")
    private Boolean isHtml;

    @Column(name = "router")
    @ApiModelProperty(value = "跳转路径")
    private String router;

    @Column(name = "type",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "类型:success/warning/info/error")
    private String type;

    @Column(name = "duration",nullable = false)
    @NotNull
    @ApiModelProperty(value = "显示时间: 毫秒，为0则不自动关闭")
    private Long duration;

    @Column(name = "create_by")
    @ApiModelProperty(value = "创建人")
    private String createBy;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建日期")
    private Timestamp createTime;

    public void copy(NotifyAnnounce source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}